{{include file='layout/header.tpl'}}

{{$data.select = $data.select->fetchAll()}}
{{$data.link = $data.link->fetchAll()}}

<form method="post" action="{{$_param.page}}">
<input type="hidden" name="_edit_link" value="1" />
<input type="hidden" name="_target[a]" value="{{$data.solo->post_id}}" />
<input type="hidden" name="_yaku[a]" value="{{$data.select[0]->yaku_id}}" />
<input type="hidden" name="_sort[a]" value="1" />
{{foreach $data.link as $index => $post}}
<input type="hidden" name="_default[]" value="{{$post->child_id}}" />
{{/foreach}}
<table class="table_edit table_form">
{{foreach $data.select as $yaku}}
<tr class="link_form_add"
 et_target="{{$_param.edit}}api/{{$target}}"
 et_yaku="{{$yaku->yaku_id}}"
 et_me="{{$data.solo->post_id}}{{foreach $data.link as $post}}{{if $yaku->yaku_id == $post->yaku_id}},{{$post->child_id}}{{/if}}{{/foreach}}"
 et_remove="{{$smarty.config.remove}}">
<th>{{$yaku->name}}</th>
<td>
<input type="text" placeholder="{{$yaku->name}}{{$smarty.config.search}}" class="add" />
<span class="add_link" style="display:none;">{{$smarty.config.notfound}} <a et_href="{{$_param.edit}}{{$target}}/0?name=" target="_blank">{{$smarty.config.newpost}}</a></span>
<hr/>
<ul class="sortable">
{{foreach $data.link as $index => $post}}
{{if $yaku->yaku_id == $post->yaku_id}}
<li class="link_form">
<button class="remove">{{$smarty.config.remove}}</button>
<input type="hidden" class="link_form_target" name="_target[{{$index}}]" value="{{$post->child_id}}" />
<input type="hidden" name="_yaku[{{$index}}]" value="{{$post->yaku_id}}" />
<input type="hidden" name="_sort[{{$index}}]" value="{{$index}}" />
{{$post->name}}
<input type="text" name="_note[{{$index}}]" value="{{$post->note}}" placeholder="{{$smarty.config.note}}" />
</li>
{{/if}}
{{/foreach}}
</ul>
</td>
</tr>
{{/foreach}}
</table>
{{include 'form/submit.confirm.tpl'}}
</form>

{{include file='layout/footer.tpl'}}